package com.spring.study.bean.definition;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * 构造器自动注入
 */
public class AutoWiringConstructorDependencyConstructorInjectionDemo {


    public static void main(String[] args) {
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);

        String xmlPath = "classpath:/META-INF/autowiring-dependency-constructor-injection.xml";
        //加载xml资源，解析并生成beanDefinition
        beanDefinitionReader.loadBeanDefinitions(xmlPath);
        //依赖查找并创建bean
        UserHolder userHolder = beanFactory.getBean(UserHolder.class);
        System.out.println(userHolder);
    }
}
